// 1- 引入（依赖）mongoose模块
const mongoose = require("mongoose");
// 2- 连接
console.log(mongoose.connection.readyState);// 0 未连接上数据库  1 已经连接上了数据库
mongoose.connect("mongodb://127.0.0.1:27017/dahaida",{
	serverSelectionTimeoutMs:2000
}).then(()=>{
	console.log("连接数据库成功",mongoose.connection.readyState);// 1
},reason=>{
	console.log("连接数据库失败",reason);
})